package com.iplatform.iplatformuser.function.mate.api.v1;

import com.iplatform.iplatformuser.function.mate.service.inter.IMateService;
import com.iplatform.module.privilege.CompatibilityBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 *
* Title: ApiMateController
* Description:
* @author 周宇华
* @date 2019年5月21日
 */
@Api(tags ="mate表接口")
@Controller
@RequestMapping("/api/v1/mate")
public class ApiMateController {

	@Autowired
	private IMateService mateService;

	@ApiOperation(value="初始化mate表")
	@RequestMapping(value="init", method= RequestMethod.POST)
	public ResponseEntity<CompatibilityBean> init(HttpServletRequest request,
												  @RequestParam @ApiParam(hidden=true) Map<String, String> formMap){
		CompatibilityBean bean=new CompatibilityBean();
		try {
			mateService.init();
			bean.setId("200");
			bean.setCode("初始化成功");
		} catch (Exception e) {
			bean.setId("400");
			bean.setCode("初始化失败");
		}
		return new ResponseEntity<>(bean, HttpStatus.OK);
	}
}
